import axios from 'axios';
import { Modal } from 'iview';
import store from './store';
var instance = axios.create({ //axios的全局配置-
    // baseURL: 'http://115.29.104.243:63334/api/',//正式环境
    // baseURL: 'http://120.77.69.221:8105/api/',//测试环境
    baseURL: 'http://localhost:10996/api/',//本地配置
    headers: { 'X-Requested-With': 'XMLHttpRequest' }, //请求头
    withCredentials: true
});
instance.interceptors.request.use(config => {
    store.dispatch('loadingShow');
    return config;
}, function(error) {
    store.dispatch('loadingHide');
    return Promise.reject(error);
})
instance.interceptors.response.use(response => {
    store.dispatch('loadingHide');
    return response;
    
}, function(error) {
    Modal.warning({ title: "提示信息", content: "网络异常,请稍后重试!!!" });
    store.dispatch('loadingHide');
    return Promise.reject(error);
    
})

export default instance;